<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<div th:replace="admin/module/_header"></div>
<div class="wrapper">
    <!-- 菜单栏模块 -->
    <div th:replace="admin/module/_sidebar"></div>
    <div class="content-wrapper">
        <section class="content-header">
            <h1>
                角色列表
                <small></small>
            </h1>
            <ol class="breadcrumb">
                <li>
                    <a data-pjax="true" href="/admin">
                        <i class="fa fa-dashboard"></i> 首页</a>
                </li>
                <li><a data-pjax="true" href="#">角色管理</a></li>
                <li class="active">角色列表</li>
            </ol>
        </section>
        <section class="content container-fluid">
            <div class="row">
                <div class="col-xs-12" style="margin-bottom: 10px;">
                    <a class="btn btn-primary" href="/admin/role/new">
                        <i class="fa fa-plus"></i> 新增
                    </a>
                </div>
                <div class="col-md-12">
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">角色列表</h3>
                        </div>
                        <div class="box-body table-responsive">
                            <table class="table table-hover">
                                <thead>
                                <tr>
                                    <th>角色编码</th>
                                    <th>角色名称</th>
                                    <th>角色等级</th>
                                    <th class="col-md-3">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr th:each="role : ${roles}">
                                    <td>[[${role.role}]]</td>
                                    <td>[[${role.description}]]</td>
                                    <td>[[${role.level}]]</td>
                                    <td>
                                        <a th:href="'/admin/role/edit?id='+${role.id}"
                                           class="btn btn-primary btn-xs ">修改</a>
                                        <button class="btn btn-danger btn-xs delete-role"
                                                th:onclick="'removeIt('+${role.id}+')'">删除
                                        </button>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="box-footer clearfix">
                            <div class="no-margin pull-left">
                                第 [[${pageInfo.current}]] / [[${pageInfo.pages}]] 页
                            </div>
                            <ul class="pagination no-margin pull-right">
                                <li><a data-pjax="true"  th:classappend="${pageInfo.current == 1 ? 'disabled' : ''}" class="btn btn-sm"
                                       th:href="'/admin/role?sort='+${sort}+'&order='+${order}">
                                    首页
                                </a>
                                </li>
                                <li><a data-pjax="true" class="btn btn-sm"  th:classappend="${pageInfo.current == 1 ? 'disabled' : ''}"
                                       th:href="'/admin/role?page='+${pageInfo.current-1}+'&sort='+${sort}+'&order='+${order}">
                                    上一页
                                </a>
                                </li>
                                <li><a data-pjax="true" class="btn btn-sm"  th:classappend="${pageInfo.current >= pageInfo.pages ? 'disabled' : ''}"
                                       th:href="'/admin/role?page='+${pageInfo.current+1}+'&sort='+${sort}+'&order='+${order}">
                                    下一页
                                </a>
                                </li>
                                <li><a data-pjax="true" class="btn btn-sm" th:classappend="${pageInfo.current >= pageInfo.pages ? 'disabled' : ''}"
                                       th:href="'/admin/role?page='+${pageInfo.pages}+'&sort='+${sort}+'&order='+${order}">
                                    尾页
                                </a>
                                </li>
                            </ul>
                        </div>

                    </div>
                    
                </div>
            </div>
        </section>
        <script>

            function removeIt(id) {
                layer.confirm('你确定是否删除', function (index) {
                    $.ajax({
                        type: "POST",
                        url: '/admin/role/delete?id=' + id,
                        async: false,
                        success: function (data) {
                            if (data.code == 0) {
                                showMsg(data.msg, "error", 1000);
                            } else {
                                window.location.reload();
                            }

                        }
                    });
                    layer.close(index);
                });
            }

        </script>
    </div>
</div>
<div th:replace="admin/module/_footer"></div>

